package com.wmx.thread.deadLock;

public class DeadLockTest {

    public static void main(String[] args) {
        Runnable runnableOne = (()->{
            synchronized (A.class){
                try {
                    Thread.sleep(1000);
                    System.out.println(Thread.currentThread().getName());
                }catch (Exception e){
                    e.printStackTrace();
                }

                synchronized (B.class){
                    System.out.println(Thread.currentThread().getName());
                }
            }
        });



        Runnable runnableTwo = (()->{
            synchronized (B.class){
                try {
                    Thread.sleep(1000);
                }catch (Exception e){
                    e.printStackTrace();
                }

                synchronized (A.class){
                    System.out.println(Thread.currentThread().getName());
                }
            }
        });


        new Thread(runnableOne).start();
        new Thread(runnableTwo).start();
    }



public static class A{}
public static class B{}
}
